package kr.lgh.sms_creditcard;

import kr.lgh.sms_creditcard.Card.CardToList;
import kr.lgh.sms_creditcard.Category.CategoryToList;
import kr.lgh.sms_creditcard.Month.MonthToList;
import kr.lgh.sms_creditcard.Setting.SettingActivity;
import android.app.Activity;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;

public class MainActivity extends Activity {
	
	ImageView[] btnArr = new ImageView[4];												
	int idArr[] = {R.id.btnMonth, R.id.btnCard, R.id.btnSetting, R.id.btnUpdateDB};		
	Intent intent = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mainlayout);
		
		for(int i=0; i<btnArr.length; i++){
			btnArr[i] = (ImageView)findViewById(idArr[i]);
			btnArr[i].setOnTouchListener(new OnTouchListener() {
				
				public boolean onTouch(View v, MotionEvent event) {
					ImageView view = (ImageView)v;
					
					switch(event.getAction()){
					case MotionEvent.ACTION_DOWN:
						Log.d("TAG", "ACTION_DOWN");
						view.getDrawable().setColorFilter(0x77000000,PorterDuff.Mode.SRC_ATOP);
						view.invalidate();
						break;
						
					case MotionEvent.ACTION_UP:
						Log.d("TAG", "ACTION_UP");
						view.getDrawable().clearColorFilter();
						view.invalidate();
					}
					return false;
				}
			});
			btnArr[i].setOnClickListener(new ImageView.OnClickListener() {
				@Override
				public void onClick(View v) {
					Log.d("TAG", "setOnClickListener");
					
					switch(v.getId()){
					
					case R.id.btnMonth:
						Log.d("SMS_TAG", "월별 화면");
						intent = new Intent(MainActivity.this, MonthToList.class);						
						break;
						
					case R.id.btnCard:
						Log.d("SMS_TAG", "카드 화면");
						intent = new Intent(MainActivity.this, CardToList.class);
						break;
						
					case R.id.btnSetting:
						Log.d("SMS_TAG", "설정 화면");
						intent = new Intent(MainActivity.this, SettingActivity.class);
						break;
						
					case R.id.btnUpdateDB:
						Log.d("SMS_TAG", "DB Load 화면");
						intent = new Intent(MainActivity.this, CategoryToList.class);
						break;
						
					}
					startActivity(intent);
				}
			});
		}
	}
}
